package helper.scxml.scxml2.t0.case3_factoryLines

import helper.base.LHMHelper.A2LHMExpand.toStr
import helper.base.debug.DebugHelper.DebuggerList
import helper.base.debug.DebugHelper.DebuggerList.Companion.makeDebuggerList
import helper.base.debug.DebugRes.d_randomRun
import helper.scxml.scxml2.zone.t2.T3SNodeUnitHelper.T3SNodeUnit
import helper.scxml.scxml2.zone.t2.ZoneEnvTestHelper.test_randomRun
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.FLEnv.Companion.makeFLEnv
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.FLT3StrategyEx.Companion.makeFLT3StrategyEx
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.ER.aB2D2FLStrategy
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.ER.makeT1FLStrategy
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.ER.makeT2FLStrategy
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.ER.makeUniformFLStrategy
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.Env.getT1StringEnvStrategyLHM
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.StrategyObj.Ren.getB2D2UniformStringRenStrategyLHM
import org.junit.Test

internal class FLEnvHelperTest {
    @Test
    fun test_printlnHIF() {
        makeFLEnv(1).run {
            printlnHIF()
        }
    }

    @Test
    fun tes_getT1StringEnvStrategyLHM(){
        getT1StringEnvStrategyLHM().let {
            println(it.toStr())
        }
    }

    private fun test_flZoneEnv_randomRun(
        strategy: T3SNodeUnit,
        debuggerList: DebuggerList = makeDebuggerList(),
    ) {
        val env = makeFLEnv()
        test_randomRun(env, strategy, debuggerList)
    }

    @Test
    fun t1_test_flZoneEnv_randomRun() {
        test_flZoneEnv_randomRun(
            makeT1FLStrategy(),
            debuggerList = makeDebuggerList(),
        )
        //(t=60.0,A1=10.0,B1=30.0,A1C1=19.0)
    }

    @Test
    fun t2_test_flZoneEnv_randomRun() {
        test_flZoneEnv_randomRun(
            makeT2FLStrategy(),
            debuggerList = makeDebuggerList(),
        )
    }

    @Test
    fun t1_t1cal() {
        val debuggerList = makeDebuggerList()
        val env = makeFLEnv()
        val t3SNodeUnit = makeT1FLStrategy()
        val cal = env.aT1Calculate(
            t3SNodeUnit,
            debuggerList,
        )
        println(cal)
        //{t=60.0, A1=10.0, A2=0.0, B1=30.0, B2=0.0, A1C1=19.0, B1C2=0.0, A2D1=0.0, B2D2=0.0}
    }

    @Test
    fun t2_t1cal() {
        val debuggerList = makeDebuggerList()
        val env = makeFLEnv()
        val t3SNodeUnit = makeT2FLStrategy()
        val cal = env.aT1Calculate(
            t3SNodeUnit,
            debuggerList,
        )
        println(cal)
    }

    @Test
    fun t3_t0cal() {
        val debuggerList = makeDebuggerList(
//            d_randomRun_runResult,
        )
        val t3SNodeUnit = makeUniformFLStrategy()
        println("nowStrategy=${t3SNodeUnit.toStr0()}")
        val cal = makeFLEnv(
            60.0,
        ).aT0Calculate(
            aSNU = t3SNodeUnit,
            debuggerList = debuggerList,
        )
        println(cal)
    }

    @Test
    fun aB2D2T3Strategy_t0cal() {
        val debuggerList = makeDebuggerList(
//            d_randomRun,
//            d_randomRun_runResult,
        )
        val t3SNodeUnit = aB2D2FLStrategy
        println("nowStrategy=${t3SNodeUnit.toStr0()}")
        val cal = makeFLEnv(
            60.0,
        ).aT0Calculate(
            aSNU = t3SNodeUnit,
            debuggerList = debuggerList,
        )
        println(cal)
    }

    @Test
    fun t3_t1cal() {
        val debuggerList = makeDebuggerList(
//            d_randomRun_runResult,
        )
        val t3SNodeUnit = makeUniformFLStrategy()
        println("nowStrategy=${t3SNodeUnit.toStr0()}")
        val cal = makeFLEnv(
            15.0,
        ).aT1Calculate(
            aSNU = t3SNodeUnit,
            debuggerList = debuggerList,
        )
        println(cal)
    }

    @Test
    fun aB2D2T3Strategy_t1cal() {
        val debuggerList = makeDebuggerList(
//            d_randomRun_runResult,
        )
        val t3SNodeUnit = aB2D2FLStrategy
        println("nowStrategy=${t3SNodeUnit.toStr0()}")
        val cal = makeFLEnv(
            15.0,
        ).aT1Calculate(
            aSNU = t3SNodeUnit,
            debuggerList = debuggerList,
        )
        println(cal)
    }

    @Test
    fun t_getB2D2UniformStringRenStrategyLHM_aT0Calculate() {
        val nowStrategy = makeFLT3StrategyEx().makeMyStrategy(
            getB2D2UniformStringRenStrategyLHM()
        )
        val env = makeFLEnv(20)

        val cal = env.aT0Calculate(
            aSNU = nowStrategy,
            repeatTimes = 1,
            debuggerList = makeDebuggerList(
                d_randomRun,
            ),
        )

        println(
            "cal=${cal}"
        )
    }
    //cal={t=20.0, A1=3.0, A2=0.0, B1=0.0, B2=1.0, A1C1=5.0, B1C2=0.0, A2D1=0.0, B2D2=4.0}

    @Test
    fun t_getB2D2UniformStringRenStrategyLHM_aT1Calculate() {
        val nowStrategy = makeFLT3StrategyEx().makeMyStrategy(
            getB2D2UniformStringRenStrategyLHM()
        )
        val env = makeFLEnv(20)

        val cal = env.aT1Calculate(
            aSNU = nowStrategy,
            debuggerList = makeDebuggerList(
                d_randomRun,
            ),
        )

        println(
            "cal=${cal}"
        )
    }
    //cal={t=20.0, A1=3.0, A2=0.0, B1=0.0, B2=1.0, A1C1=5.0, B1C2=0.0, A2D1=0.0, B2D2=4.0}
}